/**
 * 
 */
package ro.dandanciu.webgallery.domainmodel;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author Dan
 *
 */
@Entity
@Table(name="TA_USER")
@NamedQueries ( {
	@NamedQuery(
			name = "User.GetAll", 
			query = "select u from User u where u.userId LIKE :filter or u.userName LIKE :filter")	
}
)
public class User implements Comparable<User>{

	/**
	 * The user id, used to login.
	 * Mapped to K_USER.
	 */
	@Id
	@Column(name="K_USER", length=30)
	private String userId;
	
	
	/**
	 * The full name of the user
	 * Mapped to C_USERNAME.
	 */
	@Column(name="C_USERNAME", length=60) 
	private String userName;
	
	
	/**
	 * The password, used at login.
	 * Mapped to C_PASSWORD.
	 * 
	 */
	@Column(name="C_PASSWORD", length=20) 
	private String password;
	
	/**
	 * The email of user.
	 * Mapped to C_EMAIL.
	 */
	@Column(name="C_EMAIL", length=50) 
	private String email;
	
	@Column(name="C_LANG", length=10) 
	private String language;
	
	/**
	 * Is the user administrator.
	 * Mapped to B_ADMIN.
	 */
	@Column(name="B_ADMIN") 
	private boolean admin;
	
	/**
	 * The timestamp of the last time this item was updated.
	 * Mapped to D_UPDATED.
	 */
	@Column(name="D_UPDATED")
	@Temporal(value=TemporalType.TIMESTAMP)
	private Date updated;
	
	/**
	 * The user id/software which has performed the last update.
	 * Mapped to C_UPDATER.
	 */
	@Column(name="C_UPDATER", length=30) 
	private String updater;
	
	
	
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public boolean isAdmin() {
		return admin;
	}
	public void setAdmin(boolean admin) {
		this.admin = admin;
	}
	public Date getUpdated() {
		return updated;
	}
	public void setUpdated(Date updated) {
		this.updated = updated;
	}
	public String getUpdater() {
		return updater;
	}
	public void setUpdater(String updater) {
		this.updater = updater;
	}
	public int compareTo(User o) {
		return o.getUserId().compareTo(userId);
	}
	public String getLanguage() {
		return language;
	}
	public void setLanguage(String language) {
		this.language = language;
	} 
	
}
